<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <textarea id="txt"></textarea>
    <input type="button" id="btn" value="发送">
    <textarea id="res" disabled></textarea>
</body>
<script>
    var arr = ["你好", "abc", "哈哈"];
    
    var otxt = document.getElementById("txt");
    var ores = document.getElementById("res");
    var obtn = document.getElementById("btn");


    obtn.onclick = function(){
        // otxt.value
        var str = otxt.value;

        // var reg0 = /(你好)+/g;
        // console.log(reg0);

        for(var i=0;i<arr.length;i++){
            // 注意构造函数方式创建正则的语法
            var reg = new RegExp("("+arr[i]+")+", "g");
            str = str.replace(reg, "***");
        }

        ores.value = str;

    }
    
    
</script>
</html>